import Vue from "vue";
import "./plugins/axios";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "element-ui/lib/theme-chalk/index.css";
import "./plugins/element.js";
import "./plugins/wyz-echarts/wyz-echarts.js";
Vue.config.productionTip = false


//  在访问每一个路由前调用。
router.beforeEach((to, from, next) => {
      if (to.meta.requireAuth) {
        if (store.state.user.username) {
          next()
        } else {
          next({
            path: '/',
            query: {redirect: to.fullPath}
          })
        }
      } else {
        next()
      }
    }
)


/* eslint-disable no-new */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')